﻿<Window x:Class="BusinessIntelligenceToolkit.Demo.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:bit="clr-namespace:BusinessIntelligenceToolkit.Controls;assembly=BusinessIntelligenceToolkit"
        xmlns:conv="clr-namespace:BusinessIntelligenceToolkit.Demo.Converters"
        xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
        xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
        xmlns:wf="clr-namespace:BusinessIntelligenceToolkit.Demo"
        Title="Weather History Demo"
        Width="725"
        Height="500"
        WindowState="Maximized">
    <Window.Resources>
        <conv:WeatherToTextConverter x:Key="_weatherToTextConverter" />
        <conv:WeatherToUrlConverter x:Key="_weatherToUrlConverter" />

        <SolidColorBrush x:Key="_backgroundBrush">CornflowerBlue</SolidColorBrush>

        <DataTemplate x:Key="_weatherTemplate">
            <Border x:Name="border"
                    Margin="2"
                    Background="Transparent"
                    BorderBrush="CornflowerBlue"
                    BorderThickness="1"
                    CornerRadius="4"
                    SnapsToDevicePixels="True"
                    UseLayoutRounding="True">
                <Grid Margin="4">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="Auto" />

                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="Auto" />


                    </Grid.ColumnDefinitions>

                    <Image Source="{Binding Weather, Converter={StaticResource _weatherToUrlConverter}}" Stretch="None" />

                    <Grid Grid.Column="1">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="*" />
                        </Grid.RowDefinitions>

                        <TextBlock Grid.Row="0" Text="{Binding Number, StringFormat=#{0}}" FontSize="12" />

                        <TextBlock Grid.Row="1" Text="{Binding DateTime, StringFormat={}{0:H:mm MMM dd yyyy}}" FontSize="12"  />

                        <TextBlock Grid.Row="2" Text="{Binding Weather, Converter={StaticResource _weatherToTextConverter}}" FontSize="10" Margin="0,5,0,0" />
                    </Grid>
                </Grid>
            </Border>
            <DataTemplate.Triggers>
                <Trigger Property="bit:BitListBox.IsSelectedItem" Value="True">
                    <Setter TargetName="border" Property="BorderBrush" Value="Yellow" />
                </Trigger>
            </DataTemplate.Triggers>
        </DataTemplate>

        <Style TargetType="{x:Type Button}">
            <Setter Property="Width" Value="100"/>
        </Style>
    </Window.Resources>

    <Grid TextBlock.FontFamily="Book Antiqua"
          TextBlock.FontStyle="Italic"
          TextBlock.Foreground="LemonChiffon">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="450" />
        </Grid.ColumnDefinitions>

        <Image Grid.ColumnSpan="2"
               Source="Images/Background.png"
               Stretch="UniformToFill" />

        <bit:BitListBox x:Name="bitListBox"
                        Margin="20"
                        HorizontalAlignment="Stretch"
                        HorizontalContentAlignment="Stretch"
                        Background="Transparent"
                        ItemsSource="{Binding History}"
                        ItemTemplate="{StaticResource _weatherTemplate}">
            <bit:BitListBox.Animation>
                <DoubleAnimation Duration="00:00:00.5">
                    <DoubleAnimation.EasingFunction>
                        <SineEase EasingMode="EaseOut" />
                    </DoubleAnimation.EasingFunction>
                </DoubleAnimation>
            </bit:BitListBox.Animation>
        </bit:BitListBox>

        <Border Grid.Column="1"
                Margin="0,20,0,0"
                BorderThickness="0">
            <StackPanel>
                <StackPanel.Resources>
                    <Style TargetType="{x:Type Expander}">
                        <Setter Property="Foreground" Value="LemonChiffon" />
                        <Setter Property="FontFamily" Value="Book Antiqua" />
                        <Setter Property="FontStyle" Value="Italic" />
                    </Style>

                    <Style TargetType="{x:Type RadioButton}">
                        <Setter Property="Foreground" Value="LemonChiffon" />
                        <Setter Property="FontFamily" Value="Book Antiqua" />
                        <Setter Property="FontStyle" Value="Italic" />
                        <Setter Property="Margin" Value="0,0,5,0" />
                    </Style>
                </StackPanel.Resources>

                <GroupBox Header="Layout" BorderBrush="Red" BorderThickness="2">
                    <Grid Margin="2,0,0,0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>

                        <Grid.RowDefinitions>
                            <RowDefinition />
                            <RowDefinition />
                            <RowDefinition />
                            <RowDefinition />
                            <RowDefinition />
                        </Grid.RowDefinitions>

                        <TextBlock Grid.Row="0"
                                   Grid.Column="0"
                                   Text="Horizontal Alignment:" />

                        <StackPanel Grid.Row="0"
                                    Grid.Column="1"
                                    Grid.ColumnSpan="2"
                                    HorizontalAlignment="Center"
                                        VerticalAlignment="Bottom"
                                    Orientation="Horizontal">
                            <RadioButton Content="Left"
                                         GroupName="HorizontalAlignment">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="Checked">
                                        <ei:ChangePropertyAction PropertyName="HorizontalAlignment"
                                                                 TargetName="bitListBox"
                                                                 Value="Left" />
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </RadioButton>
                            <RadioButton Content="Right" GroupName="HorizontalAlignment">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="Checked">
                                        <ei:ChangePropertyAction PropertyName="HorizontalAlignment"
                                                                 TargetName="bitListBox"
                                                                 Value="Right" />
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </RadioButton>
                            <RadioButton Content="Center" GroupName="HorizontalAlignment">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="Checked">
                                        <ei:ChangePropertyAction PropertyName="HorizontalAlignment"
                                                                 TargetName="bitListBox"
                                                                 Value="Center" />
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </RadioButton>
                            <RadioButton Content="Stretch" GroupName="HorizontalAlignment"
                                         IsChecked="True">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="Checked">
                                        <ei:ChangePropertyAction PropertyName="HorizontalAlignment"
                                                                 TargetName="bitListBox"
                                                                 Value="Stretch" />
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </RadioButton>
                        </StackPanel>

                        <TextBlock Grid.Row="1"
                                   Grid.Column="0"
                                   Margin="0,5,0,0"
                                   Text="Horizontal Content Alignment:" />

                        <StackPanel Grid.Row="1"
                                    Grid.Column="1"
                                    Grid.ColumnSpan="2"
                                    HorizontalAlignment="Center"
                                        VerticalAlignment="Bottom"
                                    Orientation="Horizontal">
                            <RadioButton Content="Left"
                                         GroupName="HorizontalContentAlignment">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="Checked">
                                        <ei:ChangePropertyAction PropertyName="HorizontalContentAlignment"
                                                                 TargetName="bitListBox"
                                                                 Value="Left" />
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </RadioButton>
                            <RadioButton Content="Right" GroupName="HorizontalContentAlignment">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="Checked">
                                        <ei:ChangePropertyAction PropertyName="HorizontalContentAlignment"
                                                                 TargetName="bitListBox"
                                                                 Value="Right" />
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </RadioButton>
                            <RadioButton Content="Center" GroupName="HorizontalContentAlignment">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="Checked">
                                        <ei:ChangePropertyAction PropertyName="HorizontalContentAlignment"
                                                                 TargetName="bitListBox"
                                                                 Value="Center" />
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </RadioButton>
                            <RadioButton Content="Stretch" GroupName="HorizontalContentAlignment"
                                         IsChecked="True">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="Checked">
                                        <ei:ChangePropertyAction PropertyName="HorizontalContentAlignment"
                                                                 TargetName="bitListBox"
                                                                 Value="Stretch" />
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </RadioButton>
                        </StackPanel>
                    </Grid>
                </GroupBox>

                <GroupBox BorderBrush="{StaticResource _backgroundBrush}"
                          BorderThickness="1"
                          Header="Data">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="50" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition />
                            <RowDefinition />
                            <RowDefinition />
                            <RowDefinition />
                        </Grid.RowDefinitions>

                        <TextBlock Grid.Row="0"
                                   Grid.Column="0"
                                   VerticalAlignment="Center"
                                   Text="Generate items(click to edit):" />
                        <TextBox Grid.Row="0"
                                 Grid.Column="1"
                                 VerticalAlignment="Center"
                                 Text="{Binding GenerateItemsCountInput,
                                                UpdateSourceTrigger=PropertyChanged}" />
                        <Button Grid.Row="0"
                                Grid.Column="2"
                                Command="{Binding Generate}"
                                Content="Generate" 
                                Margin="14,0,0,0"/>
                    </Grid>
                </GroupBox>

                <GroupBox BorderBrush="{StaticResource _backgroundBrush}"
                          BorderThickness="1"
                          Header="Animation">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="200" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition />
                            <RowDefinition />
                            <RowDefinition />
                            <RowDefinition />
                        </Grid.RowDefinitions>

                        <TextBlock Text="Function:" Grid.Column="0" Grid.Row="0" VerticalAlignment="Center"/>

                        <ComboBox x:Name="cbAnimation" Grid.Column="1" Grid.Row="0" Margin="2,2,10,2">
                            <ComboBoxItem>None</ComboBoxItem>
                            <ComboBoxItem>Back</ComboBoxItem>
                            <ComboBoxItem>Bounce</ComboBoxItem>
                            <ComboBoxItem>Circle</ComboBoxItem>
                            <ComboBoxItem>Cubic</ComboBoxItem>
                            <ComboBoxItem>Elastic</ComboBoxItem>
                            <ComboBoxItem>Exponential</ComboBoxItem>
                            <ComboBoxItem>Power</ComboBoxItem>
                            <ComboBoxItem>Quadratic</ComboBoxItem>
                            <ComboBoxItem>Quartic</ComboBoxItem>
                            <ComboBoxItem>Quintic</ComboBoxItem>
                            <ComboBoxItem IsSelected="True">Sine</ComboBoxItem>
                        </ComboBox>

                        <StackPanel Grid.Column="0" Grid.Row="1" VerticalAlignment="Center" Orientation="Horizontal">
                            <TextBlock Text="Duration: "/>
                            <TextBlock Text="{Binding ElementName=slider, Path=Value}"/>
                            <TextBlock Text=" sec"/>
                        </StackPanel>

                        <Slider x:Name="slider"
                                Minimum="0.5"
                                Maximum="10" 
                                Value="0.5" 
                                SmallChange="0.5" 
                                LargeChange="1"
                                TickFrequency="0.5" 
                                IsSnapToTickEnabled="True" 
                                Margin="2,2,10,2"
                                Grid.Column="1" Grid.Row="1"/>

                        <TextBlock Text="Mode:" Grid.Column="0" Grid.Row="2" VerticalAlignment="Center" Margin="0,2,0,0"/>
                        <StackPanel Grid.Column="1" Grid.Row="2" Orientation="Horizontal" Margin="2">
                            <RadioButton x:Name="rbIn" GroupName="EasingMode" Content="In" Tag="{x:Static EasingMode.EaseIn}"/>
                            <RadioButton x:Name="rbOut" GroupName="EasingMode" Content="Out" Tag="{x:Static EasingMode.EaseOut}" IsChecked="True"/>
                            <RadioButton x:Name="rbInOut" GroupName="EasingMode" Content="InOut" Tag="{x:Static EasingMode.EaseInOut}"/>
                        </StackPanel>
                        
                        <Button Content="Apply" Grid.Column="1" Grid.Row="3" Click="OnAnimationApplyClick" HorizontalAlignment="Left"/>
                    </Grid>
                </GroupBox>

                <GroupBox BorderBrush="{StaticResource _backgroundBrush}"
                          BorderThickness="1"
                          Header="Navigation">
                    <Grid >
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                            <ColumnDefinition />
                            <ColumnDefinition />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition />
                            <RowDefinition />
                            <RowDefinition />
                            <RowDefinition />
                        </Grid.RowDefinitions>

                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="Move to: #" />
                            <TextBox Grid.Row="0" Grid.Column="1" Text="{Binding MoveToIndex, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                        </StackPanel>

                        <Button Grid.Row="0"
                                Grid.Column="1"
                                Content="move" 
                                Command="{Binding MoveTo}"/>

                        <Button Grid.Row="1"
                                Command="{Binding Move}"
                                CommandParameter="{x:Static wf:WeatherForecastViewModel.MoveToFirstParam}"
                                Content="Move to First" 
                                Margin="0,10,0,0"/>
                        <Button Grid.Row="1"
                                Grid.Column="1"
                                Command="{Binding Move}"
                                CommandParameter="{x:Static wf:WeatherForecastViewModel.MoveToLastParam}"
                                Content="Move to Last"
                                Margin="0,10,0,0"/>
                        <Button Grid.Row="1"
                                Grid.Column="2"
                                Command="{Binding Move}"
                                CommandParameter="{x:Static wf:WeatherForecastViewModel.MoveToNextParam}"
                                Content="Move to Next"
                                Margin="0,10,0,0"/>
                        <Button Grid.Row="1"
                                Grid.Column="3"
                                Command="{Binding Move}"
                                CommandParameter="{x:Static wf:WeatherForecastViewModel.MoveToPreviousParam}"
                                Content="Move to Previous"
                                Margin="0,10,0,0"/>
                    </Grid>
                </GroupBox>

                <GroupBox BorderBrush="{StaticResource _backgroundBrush}"
                          BorderThickness="1"
                          Header="Virtualization">
                    <Grid>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="Containers count:" VerticalAlignment="Center"/>
                            <TextBlock x:Name="tbCreatedContainers" Text="0" Margin="2,0,0,0" VerticalAlignment="Center"/>
                            <Button Content="Refresh" Click="OnRefreshClick" Margin="22,0,0,0"/>
                        </StackPanel>
                    </Grid>
                </GroupBox>
            </StackPanel>
        </Border>
    </Grid>
</Window>
